package butines.kraz.entity;

import static butines.kraz.entity.MessageType.RECEIVED_DAMAGE;
import butines.core.game.GameEntity;
import butines.kraz.Kraz;

public abstract class Weapon {

	private int range;
	private int damage;
	private float perform;
	private float cooldown;
	private Kraz kraz;

	public Weapon() {
		
	}
	
	public Weapon(int range, int damage) {
		this.range = range;
		this.damage = damage;
	}

	public int getRange() {
		return range;
	}

	public void setRange(int range) {
		this.range = range;
	}

	public int getDamage() {
		return damage;
	}

	public void setDamage(int damage) {
		this.damage = damage;
	}

	public Kraz getKraz() {
		return kraz;
	}

	public void setKraz(Kraz kraz) {
		this.kraz = kraz;
	}
	
	public float getCooldown() {
		return cooldown;
	}

	public void setCooldown(float cooldown) {
		this.cooldown = cooldown;
	}

	public float getPerform() {
		return perform;
	}

	public void setPerform(float perform) {
		this.perform = perform;
	}

	public abstract void hit(Unit attacker, Unit enemy);
	
	protected void dispatch(Enum<?> type, GameEntity sender, GameEntity receiver, float delay, Object ... args) {
		getKraz().getMessageDispatcher().dispatch(type, sender, receiver, delay, args);
	}
	
	protected void damage(Unit attacker, Unit enemy) {
		dispatch(RECEIVED_DAMAGE, attacker, enemy, 0f, getDamage());
	}
	
}
